<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title></title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<script  type="text/javascript">
	
	//var menuNodeList;
	$(function (){
			//初始化所有项目被测件列表
			menuList = $("#menuList").bootstrapTable({
				url : '${_baseUrl}/codeCompare/selectReportWordList?rand='+Math.random(),
				pagination: true,
				data:{},
				queryParams: queryParams,
				pageList: [5, 10, 20, 50],
				clickToSelect : false,
		        columns: [{
		        	 field: 'index',
		             width: 35,
		             height: 50,
		             align: 'center',
		             title:'序号',
	            	 formatter : function(value, row, index) {
	     				return index+1;
	     			}
		         },{
		             field: 'id',
		             title: 'id',
		             visible:false,
		             width: 5,
		             align: 'center'
			     },{
		        	 field : 'projectOldName',
		         	 title : '老版本项目名称',
		         	 width: 150,
		             height: 50,
		             align: 'center',
		             
		         },{
		        	 field : 'configOldName',
		         	 title : '老版本配置项名称',
		             width: 150,
		             height: 50,
		             align: 'center',
		             
		         },{
		        	 field : 'configOldVersion',
		         	 title : '老版本',
		             width: 120,
		             height: 50,
		             align: 'center'
		         },{
		        	 field : 'projectNewName',
		         	 title : '新版本项目名称',
		         	 width: 150,
		             height: 50,
		             align: 'center',
		             
		         },{
		        	 field : 'configNewName',
		         	 title : '新版本配置项名称',
		             width: 150,
		             height: 50,
		             align: 'center',
		             
		         },{
		        	 field : 'configNewVersion',
		         	 title : '新版本版本',
		             width: 120,
		             height: 50,
		             align: 'center'
		         },{
		        	 field : 'oper',
		         	 title : '操作',
		             width: 120,
		             height: 50,
		             align: 'center',
		             formatter: function(value, row, index){
		             	return "<a href='javascript:void(0)' onclick=\"downReportWord('"+row.id+"')\">下载</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
		             	       "<a href='javascript:void(0)' onclick=\"deleteReportWord('"+row.id+"')\">删除</a>";
		             }
		         }],
		        onLoadSuccess : function(data) {
		        	var cellIndex=parseInt($(".table_inline th").length);
		            $(".table_inline tr td").each(function(){
		                if(this.cellIndex != cellIndex){
		                    $(this).attr("title",$(this).text());
		                }
		            });
		  		}
		    });
		

		function queryParams(params){
			return {
				 pageSize: params.limit,
				    pageNo: params.pn,
				    sort : params.sort,
				    order : params.order,
				    projectName:$("#projectName").val()
			}
		}
	})
	
	function downReportWord(id){
		window.location.href = '${pageContext.request.contextPath}/codeCompare/downReportWord?id='+id+"&rand="+Math.random();
	}
	
	function deleteReportWord(id){
		var path = '${pageContext.request.contextPath}/codeCompare/deleteReportWord';
		 $.ajax({    
				type: "POST",    
				async: false,    
				url:path,   
				data:{
					"id":id      
				},    
				dataType:"json",    
				success: function (data) {  
					layer.msg(data.message,{shift:5,time:3000});
					refreshTable();		
				}   
			}); 
	}
	
	/* 关闭弹出框 */
	function closeWin(){
		layer.closeAll();
	}
	
	function refreshTable(){
		menuList.bootstrapTable('refresh');
	}

	document.onkeydown=function(event) 
	{ 
		e = event ? event :(window.event ? window.event : null); 
		if(e.keyCode==13){ 
			refreshTable(); 
		} 
	} 
	function compare(){
		var row=$("#menuList").bootstrapTable('getSelections');
		if(row == null || row.length !=2){
			layer.msg("请选择两个不同版本软件源码比对");
			return;
		}
		var ids = row[0].id + "," + row[1].id;
		$.ajax({
            //请求方式
            type : "POST",
            //请求地址
            url : "${pageContext.request.contextPath}/codeCompare/compareIncoming",
            //数据，json字符串
            data : {"configIds":ids},
            //请求成功
            success : function(result) {
                console.log(result);
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
	}
	
	function reportDown(){
		
		 var path = "${_baseUrl}/codeCompare/showReportWord?rand="+Math.random();
		   layerIndex = layer.open({
				 type: 2,
				 title:'项目配置项',
				 area: ['700px', '350px'],
				 shade: 0.3,
				 maxmin: true,
				 anim: -1,
				 content: path,
				 success: function(){
					
				 },
				 moveEnd: function(layero){
					 
				 },cancel: function(){ 
					 layer.closeAll();
				}
			});
		   layer.full(layerIndex);
	}
</script>
<style type="text/css">
.bootstrap-table{
width:100%;
}
</style>
</head>
<body>
<div class="submenu">
    <div class="func_header">
        <span title="被测件管理" >当前位置：比对报告列表</span>
    </div>
    <div class="submenu_b">
	    <div class="search_container" style="margin:0"><!--普通搜索-->
			<div class="func_search">
				<div class="func_search_div"></div>
				<input id="projectName" type="text"  value="${projectName }" placeholder="请输项目名称..." />
				<a class="search_btn" href="javascript:;" onclick="refreshTable()"></a>
			</div>
		</div>
	</div>
    <div style="overflow: auto; width:98%;margin: auto;">
		<table class="table table-bordered table_inline" id="menuList"></table>
    </div>
 </div>
</body>
</html>
